<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/common/header.jsp"%> 
 
<div style="margin:20px 0;"></div>
<div class="easyui-panel" >
	<div style="padding:10px 60px 20px 60px">
    <form id="menuForm"  name="menuForm" method="post" action="<c:url value='/menucode/saveMenu.do'/>" >
    	<input type="hidden" name="menu_uuid" value="${menuEntity.menu_uuid}"/>
    	<!-- 父级菜单编码 -->
    	<input type="hidden" id="sup_menu_uuid" name="sup_menu_uuid" value="${menuEntity.sup_menu_uuid}"/>
    	<table cellpadding="5" style="width:100%">
    		<tr>
    			<td>菜单名称:</td>
    			<td><input class="easyui-textbox" type="text" name="menu_name" data-options="required:true" value="${menuEntity.menu_name }"/></td>    	 
    			<td>菜单URL:</td>
    			<td><input class="easyui-textbox" type="text" name="menu_url" value="${menuEntity.menu_url }"/></td>
    		</tr>
    		<tr>
    			<td>上级菜单:</td>
    			<td>
    				<input class="easyui-textbox" type="text" readonly="readonly" id="sup_menu_name" value="${menuPname}"/>
    				<a href="javascript:void(0)" class="easyui-linkbutton" iconCls="icon-search" id="selelctBtn">选择</a>
    			</td>    		 
    			<td>菜单排序值:</td>
    			<td><input class="easyui-numberbox" type="text" name="menu_orders" data-options="required:true" missingMessage="只能输入数字" value="${menuEntity.menu_orders }"/></td>
    		</tr>
    		<tr>
    			<td>备用列表URL1:</td>
    			<td><input class="easyui-textbox" name="menu_url1" value="${menuEntity.menu_url1 }"/></td>
    			<td>备用列表URL2:</td>
    			<td><input class="easyui-textbox" name="menu_url2" value="${menuEntity.menu_url2 }"/></td>
    		</tr>
    		<tr>
    			<td>菜单描述:</td>
    			<td><input class="easyui-textbox" name="menu_desc" data-options="multiline:true" value="${menuEntity.menu_desc }"/></td>
    		</tr>
    	</table>
    
	    <div style="text-align:center;padding:5px">
	    	<a href="javascript:void(0)" class="easyui-linkbutton btn" iconCls="icon-save" onclick="submitForm('menuForm')">保存</a>
	    	<a href="javascript:void(0)" class="easyui-linkbutton btn" iconCls="icon-back" onclick="back()">返回</a>
	    </div>
    </form>
    </div>
</div>
<div id="menuTree">
	<div id="ztreeObj" class="ztree"></div>
</div>
<script type="text/javascript">
	var ztreeObj;
	var setting = {
		data:{
			key: {name: "MNAME"},
			simpleData:{enable: true, idKey: "MID", pIdKey: "PID"}
		}
	}
	/*选择按钮*/
	$("#selelctBtn").click(function(){
		$.ajax({
			url: "getMenuTree.do",
			async: false,
			success: function(result){
				ztreeObj = $.fn.zTree.init($("#ztreeObj"), setting, result);
			}
		});
		openModal("#menuTree", {width:400, height:400,title:'选择上级菜单'}, selected);
	});
	/*确定按钮回调*/
	function selected(){
		var nodes = ztreeObj.getSelectedNodes();
		if(nodes && nodes.length > 0){
			$("#sup_menu_uuid").val(nodes[0].MID);
			$("#sup_menu_name").textbox("setValue", nodes[0].MNAME);
		}
	}
</script>
